import 'package:flutter/material.dart';
import '../../routers/application.dart';
import '../../model/bizmodel.dart';

class MRHistoryPage extends StatefulWidget {
  final String id;
  final List items = new List();
  final bool exchange;
  MRHistoryPage({Key key, this.id, this.exchange}) : super(key: key);

  @override
  _MRHistoryPageState createState() => _MRHistoryPageState();
}

class _MRHistoryPageState extends State<MRHistoryPage> {
  @override
  void initState() {
    super.initState();
    this.widget.items
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
      ..add({"title": "aaaa", "date": "2019-01-01", "status": "Done"})
    ;
  }

  bool isExchangeOrder(PartsOrder po) {
    return po.exchange == this.widget.exchange;
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
        top: false,
        bottom: false,
        child: ListView.builder(
            shrinkWrap: true,
            primary: false,
            itemCount: this.widget.items.length,
            padding: const EdgeInsets.all(5.0),
            itemBuilder: (context, index) {
              return GestureDetector(
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Icon(Icons.toys),
                    SizedBox(width: 15),
                    Expanded(
                      child: Text(this.widget.items[index]["title"]),
                    ),
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: <Widget>[
                        Text(this.widget.items[index]["status"]),
                        Text(this.widget.items[index]["date"],
                            style: TextStyle(fontSize: 12)),
                      ],
                    )
                  ],
                ),
                onTap: () {

                },
              );
            }));
  }
}
